import os
from PIL import Image



def screen():
    # 截图保存在手机上
    os.system('adb shell screencap -p /sdcard/a.png')
    # 图片传入电脑上
    os.system('adb pull /sdcard/a.png')


# 调用截图函数
# screen()

def getDistance():
    # 读取图片
    image = Image.open('a.png')

    # 返回的是元组，打印第0个值
    # 获取图片高度2160
    height = image.size[0]
    # 获取图片宽度1080
    width = image.size[1]

    # print(height,width)
    for w in range(530, 568):
        for h in range(2053, 2070):
            data = image.getpixel((w, h))[:3]
            if data == (83, 154, 27):
                return w, h


print('33:=',getDistance())
# 调用读取图片函数
if __name__ == '__main__':

    # while True:
    for _ in range(10):

        # screen()
        xPopition = getDistance() # 951 892
        y = xPopition[1]
        os.system('adb shell input tap 547 {}'.format(y))
        # 正在点击
        print('1')

"""
环球英才
"""